<?php
/**
 * Created by : Sandi Rizky Kharisma (sandi.informatics08@gmail.com)
 * This Class Generated for CRUD purpose only
 */
class m_simpanan_wajib extends CI_Model
{
    function __construct()
    {
        parent::__construct();
    }

    public function get($where = null, $limit = null, $offset = null)
    {
        if($where != null) $this->db->where($where);
        if($limit != null && $offset != null) $this->db->limit($limit, $offset);
        return $this->db->get("simpanan_wajib");
    }

    function get_all($limit, $uri)
    {
        $result = $this->db->get('simpanan_wajib', $limit, $uri);
        if ($result->num_rows() > 0)
        {
            return $result->result_array();
        } else
        {
            return array();
        }
    }

    function get_one($id)
    {
        $this->db->where('ID_SIMPANAN', $id);
        $result = $this->db->get('simpanan_wajib');
        if ($result->num_rows() == 1)
        {
            return $result;
        } else
        {
            return array();
        }
    }

    function insert($id_anggota, $besar_simpanan)
    {
        $data = array(

                'ID_ANGGOTA' => $id_anggota,

                'BESAR_SIMPANAN' => $besar_simpanan,

                'BULAN_SIMPANAN' => date("Y-m-d")

        );
        return $this->db->insert('simpanan_wajib', $data);
    }

    function update($id)
    {
        $data = array(

                'ID_ANGGOTA' => $id_anggota,

                'BESAR_SIMPANAN' => $besar_simpanan,

                'BULAN_SIMPANAN' => date("Y-m-d")

        );
        $this->db->where('ID_SIMPANAN', $id);
        return $this->db->update('simpanan_wajib', $data);
    }

    function delete($id)
    {
        $this->db->where('ID_SIMPANAN', $id);
        $this->db->delete('simpanan_wajib');
    }

}
?>
